// pages/home/assetChoose.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    assetId: 0,
    //账户列表
    list: [{
        title: "现金账户",
        childs: [{
            name: "现金",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/xianjinchaopiao.png?sign=979bc255330738a96ad16eea52f75ae0&t=1600353470"
          },
          {
            name: "银行卡",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/yinhangka1.png?sign=ed468e271945058a80674599d049e4e6&t=1600353483"
          },
        ]
      },
      {
        title: "虚拟账户",
        childs: [{
            name: "支付宝",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/shejiaotubiao-09.png?sign=7b9c4a5c85c8d10b958854551d85192e&t=1600353458"
          },
          {
            name: "微信",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/shejiaotubiao-01.png?sign=52a919f6c1df3aef7611723288ce7191&t=1600353446"
          },
        ]
      },
      {
        title: "负债账户",
        childs: [{
            name: "蚂蚁花呗",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/huabei.png?sign=af5a4043a2a5f18c6ebd8ca9fcf07ba8&t=1600353372"
          },
          {
            name: "京东白条",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/jingdongicon-.png?sign=1d573ea27ea82303c2a29a4b2a93ce36&t=1600353431"
          },
        ]
      },
      {
        title: "投资账户",
        childs: [{
            name: "基金",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/jijinguanliren.png?sign=62b1b189c7b80f0bc304271e5817ab96&t=1600353416"
          },
          {
            name: "余额宝",
            icon_path: "https://7375-suibianjizhang-816ww-1303172500.tcb.qcloud.la/asset/yuebao.png?sign=c6ce4cca2c1893c38b9f98414768d0df&t=1600353537"
          },
        ]
      },
    ]
  },

  //选中分类并返回上一页
  returnAsset(event) {
    var imgPath = event.currentTarget.dataset.imgPath
    var assetName = event.currentTarget.dataset.assetName
    var title = event.currentTarget.dataset.title
    console.log("assetName:" + assetName)

    var pages = getCurrentPages();

    var currPage = pages[pages.length - 1];

    var prevPage = pages[pages.length - 2];

    console.log("assetId="+this.assetId)

    if(this.assetId==0){
      prevPage.setData({
        choosed_asset1: assetName,
        assetImg1_path: imgPath,
        assetTitle1:title
      })
    }
    if(this.assetId==1){
      prevPage.setData({
        choosed_asset2: assetName,
        assetImg2_path: imgPath,
        assetTitle2:title
      })
    }

    wx.navigateBack({
      //返回上一级
      delta: 1,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '选择账户',
    }),
    this.assetId = options.id
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})